package com.sesame.controller;


import kim.sesame.framework.cas.CasProperties;
import kim.sesame.framework.cas.CasServiceApi;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@CommonsLog
@Controller
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private CasProperties cas;
    @Autowired
    private Environment env;

    @RequestMapping("/{uriPath}")
    public String index(@PathVariable("uriPath") String uriPath, HttpServletRequest request, ModelMap modelMap) {

        modelMap.put("info", env.getProperty("server.port") + env.getProperty("server.context-path"));
        modelMap.put("casLoginUrl", cas.getCasServiceUrl()+ CasServiceApi.login);
        modelMap.put("casVerifyLogin", cas.getCasServiceUrl()+ CasServiceApi.verifyLogin);
        modelMap.put("casSaveLogin", cas.getCasServiceUrl()+ CasServiceApi.saveLogin);

        return uriPath;
    }

}
